<?php
// +----------------------------------------------------------------------
// | 文件说明：用户表关联model 
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: wuwu <15093565100@163.com>
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Date: 2017-7-26
// +----------------------------------------------------------------------
namespace api\user\model;

use think\Model;


class MaterialModel extends Model
{
     // 关闭自动写入update_time字段
    protected $updateTime = false;

    public function getFormatAttr($value)
    {
        $status = [0=>'文本',1=>'图片',2=>'视频',3=>'音频',4=>'语音',5=>'综合'];
        return $status[$value];
    }

    //获取单条信息
    public function getInfo($param){
        return $this->where($param)->find();
    }

    //获取列表
     public function getList($param,$whereOr,$order,$request)
    {   
        
        return $this->alias('m')
        ->join('t_app_user u','m.userId = u.id')
        ->where($param)->where($whereOr)->order($order)
        ->field('m.*,u.realName,u.nickname')
        ->paginate(10,true,['query'=>$param,'page'=>$request['page']]);
    }

    //新增
    public function create_data($data){
        
    	return $this->allowField(true)->save($data);
    }

    //修改
    public function update_data($data){
        return $this->allowField(true)->save($data,['id'=>$data['id']]);
    }
   


}
